package com.kefu.chat.controller;

import com.kefu.chat.model.ChatEvaluate;
import com.kefu.chat.service.ChatEvaluateService;
import com.kefu.chat.vo.ChatEvaluateSearchVo;
import com.kefu.chat.vo.ChatEvaluateUpdateVo;
import com.kefu.common.controller.AbstractBaseController;
import com.kefu.common.result.Result;
import com.kefu.common.result.ResultGenerator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags = "在线评价设置")
@RestController
@RequestMapping("chat/evaluate")
public class ChatEvaluateController extends AbstractBaseController {
    @Resource
    private ChatEvaluateService chatEvaluateService;

    @PostMapping("/saveOrUpdate")
    @ApiOperation(value = "保存渠道评价配置", notes = "保存渠道评价配置")
    public Result<ChatEvaluate> update(@Validated @RequestBody ChatEvaluateUpdateVo chatEvaluateVo) {
    	logger.info("保存渠道评价配置:{}", chatEvaluateVo);

        ChatEvaluate chatEvaluate = chatEvaluateService.saveOrUpdate(chatEvaluateVo);
        return ResultGenerator.genSuccessResult(chatEvaluate);
    }
    @PostMapping("/getChatEvaluate")
    @ApiOperation(value = "获取渠道评价配置", notes = "获取渠道评价配置")
    public Result<ChatEvaluate> get(@Validated @RequestBody ChatEvaluateSearchVo search) {
        logger.info("获取渠道评价配置:{}", search);

        ChatEvaluate result = chatEvaluateService.getChatEvaluate(search);
        return ResultGenerator.genSuccessResult(result);
    }
}
